package com.itheima.test02;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

@WebServlet("/find02")
public class FindServlet02 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String path = getServletContext().getRealPath("student02.txt");
        BufferedReader br = new BufferedReader(new FileReader(path));
        response.setContentType("text/html;charset=utf-8");
        String line;
        while((line = br.readLine())!=null){
            response.getWriter().write(line+"</br>");
        }
        br.close();
    }
}
